<script language="javascript">
<!--

-->
</script>

<h3>Search Results</h3>

<form action="<?php echo site_url("bookings/step1"); ?>" method="post">
<table>
	<thead>
    	<tr>
           	<th>Tour Name</th>
            <th>Departure Date</th>
            <th><?php if ($admin) { echo 'Space remaining'; } else { echo 'Availability'; } ?></th>
            <th></th>
        </tr>
    </thead>
                
    <tbody>
    	<?php for ($i = 0; $i < count($results); $i++) { 
        $isFull = false;
		
		if (($results[$i]['passengers'] + $passengers) > $results[$i]['capacity'])
		{
			$isFull = true;	
		}
        
		
		?>
        <tr>
        	<td><a href="<?php echo site_url('tours/show/' . $results[$i]['id']); ?>"><?php echo $results[$i]['tour_name']; ?></a></td>
            <td><?php echo natural_date_for_site($results[$i]['departure'], true); ?></td>
            <td>
            <?php if ($admin)
			{
				echo $results[$i]['capacity'] - $results[$i]['passengers'];
			} else
			{
				if ($isFull) { echo 'FULL!'; }
            
            } ?>
            </td>
            <td>
            <?php if (!$isFull) { ?>
            <input type="radio" name="booking_tour" value="<?php echo $results[$i]['id']; ?>" />
            <?php } ?>
			 </td>
        </tr>
        <?php } ?>
                   
	</tbody>
</table>

<ul class="formContainer">
    <li class="floatFix">
    	<input type="hidden" name="booking_passengers" id="booking_passengers" value="<?php echo $passengers; ?>" />
        <input type="submit" class="submitButton" value="Continue >>" name="go_to_step2" id="go_to_step2" />
  	</li>
</ul>

</form>